<?php 
 include_once dirname(__FILE__)."/config.php";
 class etat_eval_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_code_etat;
		 protected $_decision;
		 public function get_name_table(){ return "etat_eval";}
		 public function get_name_code_etat(){ return "code_etat";}
		 public function get_name_decision(){ return "decision";}
		 public function set_code_etat($parametre){  $this->_code_etat=$parametre;}	
		 public function set_decision($parametre){  $this->_decision=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_code_etat(){ return $this->_code_etat;}
		 public function get_decision(){ return $this->_decision;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 etat_eval(
			decision)
 VALUES(
			'".$this->_decision."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_decision)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
decision='".$this->_decision."'";
}
$sql="UPDATE 
etat_eval SET 
 ".$sql."
								WHERE code_etat ='".$this->_code_etat."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
etat_eval 
 
									WHERE code_etat ='".$this->_code_etat."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
etat_eval ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		code_etat,
		decision
 FROM 
 etat_eval";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_code_etat=$row->code_etat;
		$this->_decision=$row->decision;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>